<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 路♥克
  Date: 2017/12/5
  Time: 2:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <base href="${pageContext.request.contextPath}/web/"/>
    <meta charset="UTF-8">
    <title>详情</title>
    <jsp:include page="elments_views/js.jsp"/>
    <link rel="stylesheet" type="text/css" href="frame/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="frame/bootstrap/css/button.css">
    <!-- 	<link rel="stylesheet" type="text/css" href="frame/bootstrap/css/bootstrap-theme.min.css"> -->
    <link rel="stylesheet" type="text/css" href="frame/css/layout.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <%--<script type="text/javascript" src="frame/myfocus/js/myfocus-2.0.1.min.js"></script>--%>
    <!--放大镜效果-->
    <script src="script/mzp-packed.js"></script>
    <link rel="stylesheet" href="css/magiczoomplus.css">
    <style type="text/css">
        .panel{margin-bottom: 0px;}
        .panel .panel-heading{border-radius: 0px;background: white;margin:0px;color: black;font-weight: bolder;font-size: 16px;padding-bottom: 0px;}
        .panel .panel-heading p.first-menu{border-left: 5px solid red;padding-left: 15px;}
        .panel .list-group li{border: none;padding-left: 50px;}
        .panel .list-group li a{color: black;}
        .panel .list-group li.active{background: #f9f9f9;font-weight: bold;}
        .panel .panel-heading p.date-source{font-weight:normal;color: #cfcfcf;}
        #img-a{margin-left: -6%;margin-top: 1px;}
        #img-a li{list-style-type:none;float: left;margin-left: 1px;width: 113px;}
        #img-a li img{height: 100%}
        #detail-attr ul{margin-left: -6%;height: 70px;margin-top: 30px}
        #detail-attr ul li{list-style-type:none;float: left;text-align: center;width: 100px;border-right: 1px solid rgba(0, 0, 0, 0.11);}
        #detail-attr ul li:last-child{border:none;}
        #detail-attr ul li h2{ color: orangered; font-weight: 600}
        .clear-css{margin: 0px;padding-top: 0px;clear: both;}
        #touch-btn{margin-top: 30px;margin-left:10px}
        .detail-c-header ul{width: 100%;height:45px;}
        .detail-c-header ul li{list-style-type:none;float: left;margin-right: 50px}
        .detail-c-header ul li a{text-decoration:none;font-size: 20px;text-align: center;color: black;height: 40px}
        .detail-c-header ul li:first-child a{
            border-bottom: 5px solid rgba(255, 209, 51, 0.78);
        }
        .detail-c-header ul li a:hover{
            border-bottom: 5px solid rgba(255, 209, 51, 0.78);
        }
        .detail-c-context-detail title{

        }
        .title-css1{
            background-color: rgba(104, 104, 104, 0.05);
        }
        .title-css{
            background-color: rgba(94,94,94,0.14);
        }
        .detail-c-context-detail-attr{
            margin: 10px;
        }
        .detail-c-context-detail-attr table tr td:nth-child(1){
            color: rgba(0, 0, 0, 0.32);
            text-align: right;
            padding-right: 20px;
        }
        .detail-c-context-detail-attr table{
            border-right: 2px solid rgba(188, 200, 213, 0.53);
        }
        .detail-c-context-detail-attr table tr td{
            width: 80px;
            height: 25px;
        }
        .detail-c-context-photo img{
            margin-bottom: 20px;
        }
    </style>
</head>
<script>
    function showgoods() {
//        alert();
        $(".carDetail").click(function () {
            $(".detail-c-header ul li a").css("border","none");
            $(this).css("border-bottom","5px solid rgba(255, 209, 51, 0.78)");
            $(".detail-context").hide();
            $("#carDetail").show();
        });
        $(".carPhoto").click(function () {
            $(".detail-c-header ul li a").css("border","none");
            $(this).css("border-bottom","5px solid rgba(255, 209, 51, 0.78)");
            $(".detail-context").hide();
            $("#carPhoto").show();
        });
        $(".carDiscuss").click(function () {
            $(".detail-c-header ul li a").css("border","none");
            $(this).css("border-bottom","5px solid rgba(255, 209, 51, 0.78)");
            $(".detail-context").hide();
            $("#carDiscuss").show();
        });
    }
</script>
<body onload="showgoods()">
<jsp:include page="elments_views/header.jsp"/>
<div class="container" style="margin-top: 120px;">
    <div class="row">
        <div class="col-md-5">
            <div class="row">
                <div class="col-bg-6 col-bg-3">
                    <a href="javascript:void(0)" class="thumbnail" style="height: 295px">
                        <div  height="200px" style="margin:auto;width: 95%; height: 200px; overflow:hidden">
                            <img id="bigimg" src="${goodsDetails.previewImgAddress}" alt="..." style="width: 100%">
                        </div>
                        <ul id="img-a">
                            <li style="height: 85px; overflow:hidden"><img src="${goodsDetails.previewImgAddress}" alt="" ></li>
                        <c:forEach var="img" items="${goodsDetails.goodsImgList}" varStatus="status">
                            <c:if test="${status.count <4}" >
                                <li style="height: 85px; overflow:hidden"><img src="${img.imgAddress}" alt="" ></li>
                            </c:if>
                        </c:forEach>
                        </ul>
                        <script>
                            $("#img-a li").click(function () {
                                $("#bigimg").attr("src",$(this).children("img").attr("src"));
                            });
                        </script>
                    </a>

                </div>
            </div>
        </div>
        <div class="col-md-7">
            <div style="margin-left: 20px">
                <h3>${goodsDetails.goodsName}</h3>
                <div style="background-color: rgba(94,94,94,0.14);width: 100%;height: 70px;padding-top:15px;padding-left: 20px;margin-top: 20px">
                    <font style="font-size: 30px;color: orangered">¥ ${goodsDetails.nowPrice}</font>万起  &nbsp;&nbsp;原价：${goodsDetails.oldPrice}万
                </div>
                <div id="detail-attr">
                    <ul>
                        <c:forEach var="GoodsAttr" items="${goodsDetails.wareGoodsAttrList}">
                        <li>
                            <h2>${GoodsAttr.attrValue}</h2>${GoodsAttr.attrName}
                        </li>
                        </c:forEach>
                    </ul>
                </div>
                <div class="clear-css"></div>
                <%--data-toggle="modal" data-target="#gridSystemModal"--%>
                <div id="touch-btn">
                    <button class="button  button-highlight button" style="border-radius: 1px;width: 200px;font-size: 20px;"><span class="glyphicon glyphicon-yen" aria-hidden="true"></span>&nbsp;立即下单</button>
                    <button class="button  button-caution button" style="margin-left:20px;border-radius: 2px;width: 200px;font-size: 20px;"><span class="glyphicon glyphicon-earphone" aria-hidden="true"></span>&nbsp;预约车辆</button>
                </div>
            </div>
        </div>
        <div class="container" >
            <div class="row clearfix">
                <div class="col-md-9 column" style="margin-top: 50px;">
                    <div>
                        <div class="detail-c-header" >
                            <ul class="title-css" style="padding-top: 1.5%">
                                <li><a href="javascript:;" class="carDetail">车源详情</a></li>
                            </ul>
                        </div>
                        <div id="carDetail" class="detail-context">
                            <div class="detail-c-context">
                                <div class="detail-c-context-detail" style="padding: 20px;">
                                    <div class="title-css1" style="height: 30px;line-height: 30px;padding-left: 10px">商品详情</div>
                                    <div style="font-size: 14px;padding-left: 10px">
                                        ${goodsDetails.goodsDetails.content}
                                    </div>
                                </div>
                                <div class="detail-c-context-photo">

                                </div>
                            </div>
                            <div class="detail-c-context">
                                <div class="detail-c-context-detail" style="padding: 20px;">
                                    <div class="title-css1" style="height: 30px;line-height: 30px;padding-left: 10px">概况</div>
                                    <div class="detail-c-context-detail-attr" style="font-size: 14px">
                                        <table>
                                            <tr>
                                                <td>商品标签编号</td>
                                                <td>${goodsDetails.goodsLabel}</td>
                                            </tr>
                                            <tr>
                                                <td>汽车品牌</td>
                                                <td>${goodsDetails.wareGoodsBrand.brandName}</td>
                                            </tr>
                                            <c:forEach var="GoodsAttr" items="${goodsDetails.wareGoodsAttrList}">
                                            <tr>
                                                <td>${GoodsAttr.attrName}</td>
                                                <td>${GoodsAttr.attrValue}</td>
                                            </tr>
                                            </c:forEach>
                                        </table>
                                    </div>
                                </div>

                            </div>
                        </div>

                    </div>
                </div>
                <div class="col-md-3 column" style="margin-top: 35px;">
                    <div class="row">
                        <div class="col-md-12" >
                            <div style="border-bottom:  2px solid #ff8310;">
                                <h3>特卖商品</h3>
                            </div>

                        </div>
                    </div>
                    <div class="row mt-20">
                        <c:forEach var="g" items="${specialList}">
                            <div class="col-sm-12 col-md-12 goods">
                                <div class="thumbnail"  style="height: 270px">
                                    <input type="hidden" value="${g.id}">
                                    <img src="${g.previewImgAddress}" alt="...">
                                    <div class="caption">
                                        <p class="goods-title">${g.goodsDescribe}</p>
                                        <p ><span style="color: #cfcfcf">市场价:<s>${g.oldPrice}万元</s></span></p>
                                        <p><span>现价<span class="now-price">${g.nowPrice}万元</span></span></p>
                                    </div>
                                </div>
                            </div>
                        </c:forEach>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal inmodal" id="UserModal1" style="margin-left: 10%;margin-top: 5%" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated flipInY" style="width: 400px;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" style="color: green">提示</h4>
            </div>
            <div id="modal-body" class="modal-body" style="padding-left: 80px;font-size: 16px">

            </div>
            <div class="modal-footer">
                <button id="resubmit" type="button" class="btn btn-primary" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
<jsp:include page="elments_views/footer.jsp"/>
</body>
</html>
<script type="text/javascript">
    $(function () {
       $("#touch-btn button").click(function () {

           <c:if test="${empty user}">
           $("#modal-body").text("您还未登陆，请先登陆后操作！");
           $("#modal-body").attr("text-align","center");
           $("#UserModal1").modal("show");
           </c:if>
           <c:if test="${not empty user and empty user.email }">
               $("#modal-body").text("请先完善你的资料！");
               $("#modal-body").attr("text-align","center");
               $("#UserModal1").modal("show");
           </c:if>
            //用户登录后可以下单或预约
               <c:if test="${not empty user.email }">
                   if($(this).text().indexOf("预约")>-1){
                       $.ajax({
                           url:"/Appointment/insertAppointment",
                           type:"GET",
                           data:{"GoodsId":${goodsDetails.id}},
                           dataType:"json",
                           success:function (json) {
                               console.info(json);
                           },
                           error:function (json) {
                               console.info(json.responseText);
                                if(json.responseText=="success"){
                                    var a="<a herf='javascript:;' class='mySubscribe' style='cursor: pointer'>我的预约</a>";
                                    $("#modal-body").text("预约成功！");
                                    $("#modal-body").append(a);
                                    $("#modal-body").attr("text-align","center");
                                    $("#UserModal1").modal("show");
                                }

                           }
                       });
                   }else{
                       $.ajax({
                           url:"/OrderInfo/insertOrderInfo",
                           type:"GET",
                           data:{"price":${goodsDetails.nowPrice}},
                           dataType:"json",
                           success:function (json) {
                               console.info(json);
                           },
                           error:function (json) {
                               console.info(json.responseText);
                               if(json.responseText=="success"){
                                   var a="<a herf='javascript:;' class='myOrder' style='cursor: pointer'>我的订单</a>";
                                   $("#modal-body").text("下单成功！");
                                   $("#modal-body").append(a);
                                   $("#modal-body").attr("text-align","center");
                                   $("#UserModal1").modal("show");
                               }

                           }
                       });
                   }
                </c:if>
       });
       $(document).on("click",".mySubscribe",function () {
           window.location.href="/Appointment/selectAppointmentByUserId";
       });
        $(document).on("click",".myOrder",function () {
            window.location.href="/OrderInfo/selectOrderInfoByUserId";
        });
    });

</script>
